/**
 *  与原生交互
 */
import 'package:flutter_benchu/utils/commonPkg.dart';



class SendNativeDemoPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => _SendNativeDemoPageState();
}

class _SendNativeDemoPageState extends State<SendNativeDemoPage> {
  String recive = '';

  //调用原生函数
  Future sendMessage(Map arguments) async {
    var result = await AppToolsPlugin.getData({'name': '小明', 'age': 25});
    var name = result['name'];
    var age = result['age'];
    Log.v(name);
    Log.v(age);
    setState(() {
      recive = "name:$name age:$age";
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('与原生交互')),
      body: Container(
        padding: EdgeInsets.fromLTRB(0, 24.w, 0, 0),
        child: Column(
          children: [
            Text(recive),
            ButtonItem(
              title: '发送数据',
              bgColor: Colors.green,
              onPressed: () {
                sendMessage({});
              },
            ),
            Text(cacheModel.uuid),
            GFButton(
              onPressed: () async {
                final _picker = ImagePicker();
                //  PickedFile image = await _picker.getImage(source: ImageSource.gallery); //从相册选择
                PickedFile image = await _picker.getImage(source: ImageSource.camera);      //拍照
              },
              text: "打开相机哦",
            ),
            GFButton(
              onPressed: () async {
                final _picker = ImagePicker();
                 PickedFile image = await _picker.getImage(source: ImageSource.gallery); //从相册选择
              },
              text: "打开相册",
            ),
          ],
        ),
      ),
    );
  }
}
